script_enemy_main{

let angle=180;
let speed=1;
let color=255;

let shot1=0;
let bullet1=[];
let timer1=[];
let bounce1=[];

let character="Kurumi";
let cutin=character;
let dispelled=0;
let spellcards=1;
let spellcardnumber=68;
let damagerate=10;
let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEshots5=("\script\SoundEffects\shots5.wav");

let BG1=("\script\Images\BackgroundLayers\Kurumi3a.png");
let BG2=("\script\Images\BackgroundLayers\Kurumi3b.png");
let GRboss=("\script\Images\CharacterSprites\Kurumi.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsKurumi1.txt");

	LoadSE("\script\SoundEffects\shots5.wav");

	LoadGraphic("\script\Images\BackgroundLayers\Kurumi3a.png");
	LoadGraphic("\script\Images\BackgroundLayers\Kurumi3b.png");
	LoadGraphic("\script\Images\CharacterSprites\Kurumi.png");

	SetScore(2500000);
	SetLife(1000);
	SetTimer(90);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,miny+100,50);

	SetDurableSpellCard;

	SetCommonData("IncreasePhase",0);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(32,32,32,32);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=0; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Influence [Superficial Charm]",spellcardnumber); 
HealthBar();
Portrait(cutin,1);


if(time%6==0 && time>=60){
SetShotColor(color,color,color);
let nr=1;
	loop(9){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX+10,GetY-30);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,speed);
	SetShotColor(color,color,color);
	if(nr==1){ ObjShot_SetGraphic(shot1,13); }
	if(nr==2){ ObjShot_SetGraphic(shot1,17); }
	if(nr==3){ ObjShot_SetGraphic(shot1,20); }
	if(nr==4){ ObjShot_SetGraphic(shot1,13); }
	if(nr==5){ ObjShot_SetGraphic(shot1,17); }
	if(nr==6){ ObjShot_SetGraphic(shot1,20); }
	if(nr==7){ ObjShot_SetGraphic(shot1,13); }
	if(nr==8){ ObjShot_SetGraphic(shot1,17); }
	if(nr==9){ ObjShot_SetGraphic(shot1,20); }
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	bounce1=bounce1~[shot1];
	bounce1[length(bullet1)-1]=0;
	angle+=360/9;
	nr++;
	}
angle+=60*cos(time/4);
color-=0.4;
usespell=10;
PlaySE(SEshots5);
}
speed+=0.0015;
if(speed>=3){ speed=1; color=255; }

let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i); bounce1=erase(bounce1,i);
	i--;
	}
	else{
	let obj=bullet1[i];
		if(bounce1[i]<1){
			if(Obj_GetX(obj)<=minx){
			Obj_SetAngle(obj,180-Obj_GetAngle(obj));
			Obj_SetX(obj,Obj_GetX(obj)+1); bounce1[i]=bounce1[i]+1;
			Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])+0.1);
			}
			if(Obj_GetX(obj)>=maxx){
			Obj_SetAngle(obj,180-Obj_GetAngle(obj));
			Obj_SetX(obj,Obj_GetX(obj)-1); bounce1[i]=bounce1[i]+1;
			Obj_SetSpeed(bullet1[i],Obj_GetSpeed(bullet1[i])+0.1);
			}
		}
	timer1[i]=timer1[i]+1;
	}
i++;
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";

if(GetLife==0 && dispelled==0){ CreateEnemyFromFile("script\Functions\dispel.txt",GetX,GetY,0,0,character); dispelled=1; }
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }

	SetGraphicRect(0,0,300,300);
	SetGraphicScale(2,2);
	SetTexture(BG1);
	SetAlpha(bgfade/2);
	SetColor(255,255,255);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,-time*2);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0,0,150,150);
	SetGraphicScale(1,1);
	SetTexture(BG2);
	SetAlpha(bgfade);
	SetColor(150,150,150);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,(45*cos(time*2)));
	DrawGraphic(cx+200*cos(90+(70*cos(time*2))),cy-50+180*sin(90+(60*cos(time*2))));
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
	if(GotSpellCardBonus){ SetCommonData("LastTrumpCard",1); }
	NewPointData(spellcardnumber,7);
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}